package com.zzy.demo.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zzy.demo.config.EnvConfig;
import com.zzy.demo.config.ServerConfig;

@Controller
public class PropertyController {
	
	@Autowired EnvConfig envConfig;
	@Autowired ServerConfig serverConfig;
	

	
	@RequestMapping("/showEnv")
	public @ResponseBody String env(){
		
		return "port:"+envConfig.getServerPort();
	}
	
	@RequestMapping("/showValue")
	public @ResponseBody String value(@Value("${server.port}")  int port){
		return "port:"+port;
	}
	
	@RequestMapping("/showServer")
	public @ResponseBody String value(){
		
		return "port:"+serverConfig.getPort()+"----contxtPath:"+serverConfig.getContextPath();
	}
}
